<template>
  <div class="jxkcsq">
    <div class="select-module">
      <el-card>
        <i class="el-icon-search" style="font-size: 30px; font-weight: bold; color: #409eff; margin: 0 20px 0 0; position: relative; top: 5px;"></i>
        <div class="select-item">
          <span>课程类别:</span>
          <el-select v-model="coursevalue1" placeholder="请选择">
            <el-option
              v-for="item in optionsValue1"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </div>
        <div class="select-item">
          <span>课程名称:</span>
          <el-input v-model="coursevalue4" placeholder="请输入">
          </el-input>
        </div>
        <div class="fr">
          <el-button type="primary" @click="findQuery">查询</el-button>
          <el-button type="danger" @click="clearParams">清除条件</el-button>
        </div>
      </el-card>
    </div>
    <el-card>
      <!--筛选条件-->
      <div class="but-group-module">
        <el-button type="primary" @click="addApply">新增课程</el-button>
      </div>
      <div class="table-module">
        <el-table
          :data="tableData"
          border
          style="width: 100%">
          <el-table-column
            prop="CourseNumber"
            label="课程号"
            width="100">
          </el-table-column>
          <el-table-column
            prop="CourseName"
            label="课程名称"
            width="100">
          </el-table-column>
          <el-table-column
            prop="Credit"
            label="学分"
            width="100">
          </el-table-column>
          <el-table-column
            prop="TotalHours"
            label="总学时"
            width="100">
          </el-table-column>
          <el-table-column
            prop="ExaminationForm"
            label="考试形式"
            width="100">
          </el-table-column>
          <el-table-column
            prop="TeachingMethods"
            label="授课方式"
            width="100">
          </el-table-column>
          <el-table-column
            prop="NoCourseNumber"
            label="不能排课节次"
            width="120">
          </el-table-column>
          <el-table-column
            prop="PracticeHours"
            label="优先排课节次"
            width="120">
          </el-table-column>
          <el-table-column
            prop="Status"
            label="进度"
            width="100">
          </el-table-column>
          <el-table-column
            label="操作"
            width="100">
            <template slot-scope="scope">
              <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-card>
    <div class="add-dialog">
      <el-dialog title="教学课程申请" :visible.sync="dialogAddVisible" width="60%" top="5vh" custom-class="add-course-dialog">
        <div class="content">
          <el-row :gutter="20">
            <el-col :span="12">
              <div class="item">
                <span class="title">选修类别：</span>
                <el-select v-model="value1" placeholder="请选择">
                  <el-option
                    v-for="item in value1Options"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="item">
                <span class="title">课程类别：</span>
                <el-select v-model="value2" placeholder="请选择">
                  <el-option
                    v-for="item in value2Options"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="12">
              <div class="item">
                <span class="title">课程号：</span>
                <el-input v-model="value3" placeholder="请输入内容"></el-input>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="12">
              <div class="item">
                <span class="title">课程名称：</span>
                <el-input v-model="value4" placeholder="请输入内容"></el-input>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="item">
                <span class="title">课程英文名：</span>
                <el-input v-model="value5" placeholder="请输入内容"></el-input>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="12">
              <div class="item">
                <span class="title">课程别名：</span>
                <el-input v-model="value6" placeholder="请输入内容"></el-input>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="item">
                <span class="title">课程费用：</span>
                <el-input v-model="value7" placeholder="请输入内容"></el-input>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="12">
              <div class="item">
                <span class="title">开课机构：</span>
                <el-select v-model="value8" placeholder="请选择">
                  <el-option
                    v-for="item in value8Options"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="item">
                <span class="title">课程系数：</span>
                <el-input v-model="value9" placeholder="请输入内容"></el-input>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="12">
              <div class="item">
                <span class="title">考试形式：</span>
                <el-select v-model="value10" placeholder="请选择">
                  <el-option
                    v-for="item in value10Options"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="item">
                <span class="title">授课方式：</span>
                <el-select v-model="value11" placeholder="请选择">
                  <el-option
                    v-for="item in value11Options"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="12">
              <div class="item">
                <span class="title">总学时：</span>
                <el-input v-model="value12" placeholder="请输入内容"></el-input>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="item">
                <span class="title">理论学时：</span>
                <el-input v-model="value13" placeholder="请输入内容"></el-input>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="12">
              <div class="item">
                <span class="title">实践学时：</span>
                <el-input v-model="value14" placeholder="请输入内容"></el-input>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="item">
                <span class="title">其他学时：</span>
                <el-input v-model="value15" placeholder="请输入内容"></el-input>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="12">
              <div class="item">
                <span class="title">参考书目：</span>
                <el-input v-model="value16" placeholder="请输入内容"></el-input>
                <span style="color: #ccc; font-size: 12px;">多本用，隔开</span>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="item">
                <span class="title">学分：</span>
                <el-input v-model="value17" placeholder="请输入内容"></el-input>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="24">
              <div class="item">
                <span class="title">课程介绍：</span>
                <el-input
                  type="textarea"
                  :rows="3"
                  placeholder="请输入内容"
                  v-model="value18">
                </el-input>
              </div>
            </el-col>
          </el-row>
          <h3>排课用优化信息</h3>
          <el-row :gutter="20">
            <el-col :span="24">
              <div class="item">
                <span class="title">不能排课节次：</span>
                <el-input v-model="value19" placeholder="请输入内容"></el-input>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="24">
              <div class="item">
                <span class="title">优先排课节次：</span>
                <el-input v-model="value20" placeholder="请输入内容"></el-input>
              </div>
            </el-col>
          </el-row>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogAddVisible = false">返 回</el-button>
          <el-button type="primary" @click="saveApplyData">保 存</el-button>
        </div>
      </el-dialog>
    </div>
    <div class="look-dialog">
      <el-dialog title="提示" :visible.sync="dialogPlanVisible" width="98%" custom-class="add-course-dialog">
        <div>查看显示的详细内容，暂时不知道哪个接口</div>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogPlanVisible = false">取 消</el-button>
          <el-button type="primary" @click="dialogPlanVisible = false">确 定</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<style lang="scss" scoped>
  .jxkcsq {
    .select-module {
      .select-item {
        display: inline-block;
        margin-right: 30px;
        .el-select, .el-input {
          width: 150px;
        }
      }
    }
    .but-group-module {
      margin-bottom: 10px;
    }
    .table-module {
      text-align: center;
      /*padding: 10px;*/
      border: 1px solid #ccc;
    }
    .add-course-dialog {
      .content {
        .el-input {
          width: 200px;
          display: inline-block;
        }
        .el-select {
          width: 200px;
        }
        .el-textarea {
          max-width: 650px;
        }
        .item {
          margin-bottom: 10px;
          span {
            display: inline-block;
            width: 100px;
          }
        }
      }
      .el-dialog__body {
        padding: 15px 20px;
      }
    }
    .red-tips {
      color: #f33;
    }
  }
</style>

<script>
  import {getToken} from "../../utils/auth";

  export default {
    data() {
      return {
        coursevalue1: '',
        coursevalue4: '',
        optionsValue1: [
          {
            value: '必修课程',
            label: '必修课程'
          },
          {
            value: '选修课程',
            label: '选修课程'
          }
        ],
        tableData: [],
        currentPageValue: 1, // 当前第几页
        pageNum: 10, // 每页数量
        totalData: '',
        dialogPlanVisible: false,
        dialogAddVisible: false,
        // 弹框里的值
        value1: '',
        value1Options: [
          {
            value: '选修课程',
            label: '选修课程',
          },
          {
            value: '必修课程',
            label: '必修课程',
          }
        ],
        value2: '',
        value2Options: [
          {
            value: '文化课',
            label: '文化课',
          },
          {
            value: '专业课',
            label: '专业课',
          }
        ],
        value3: '',
        value4: '',
        value5: '',
        value6: '',
        value7: '',
        value8: '',
        value8Options: [
          {
            value: '学校结构',
            label: '学校结构',
          }
        ],
        value9: '',
        value10: '',
        value10Options: [
          {
            value: '考试',
            label: '考试',
          },
          {
            value: '考察',
            label: '考察',
          }
        ],
        value11: '',
        value11Options: [
          {
            value: '面授讲课',
            label: '面授讲课',
          },
          {
            value: '辅导',
            label: '辅导',
          },
          {
            value: '录像讲课',
            label: '录像讲课',
          },
          {
            value: '网络教学',
            label: '网络教学',
          },
          {
            value: '实验',
            label: '实验',
          },
          {
            value: '实习',
            label: '实习',
          },
          {
            value: '其他',
            label: '其他',
          },
        ],
        value12: '',
        value13: '',
        value14: '',
        value15: '',
        value16: '',
        value17: '',
        value18: '',
        value19: '',
        value20: '',
      }
    },
    methods: {
      handleClick(params) {
        this.dialogPlanVisible = true
      },
      findQuery() {
        this.loadTableData()
      },
      clearParams() {
        this.coursevalue1 = ''
        this.coursevalue4 = ''
      },
      addApply() {
        this.dialogAddVisible = true
      },
      async loadTableData() {
        let params = {
          token: getToken(),
          index: this.currentPageValue,
          pagemax: this.pageNum,
          category: this.coursevalue1,
          name: this.coursevalue4,
        }
        let res = await this.axios.get('v1/jxkc/getdata', {params: params})
        // console.log('哈哈')
        // console.log(res)
        let resData = res.data
        this.tableData = resData.data
        this.totalData = resData.count
        // console.log(this.tableData)
      },
      async saveApplyData() {
        this.dialogAddVisible = false
        let params = {
          token: getToken(),
          electiveCategory: this.value1,
          CourseCategory: this.value2,
          CourseId: this.value3,
          CourseName: this.value4,
          CourseEnName: this.value5,
          CourseAlias: this.value6,
          CourseCost: this.value7,
          OpeningInstitution: this.value8,
          OpeningCoefficient: this.value9,
          ExaminationForm: this.value10,
          TeachingMethods: this.value11,
          TotalHours: this.value12,
          TheoreticalHours: this.value13,
          PracticeHours: this.value14,
          OtherHours: this.value15,
          Bibliography: this.value16,
          Credit: this.value17,
          CourseIntroduction: this.value18,
          CourseNumber: this.value19,
          NoCourseNumber: this.value20,
        }
        let res = await this.axios.post('v1/jxkc/add_action', params)
        console.log('申请保存')
        console.log(res)
        if (res.data.code === 200) {
          this.$message({
            message: '保存成功',
            type: 'success'
          });
          this.loadTableData()
        }
      }
    },
    created() {
      this.loadTableData()
    }
  }
</script>
